home *** CD-ROM | disk | FTP | other *** search
- global gVariable, gCast, gSize, gSecondColor, gEraserMask, gEraserSize, myCurrentImage, myCurrentPreview
-
- on tool1PxEraser
- member("state1 - " & gSize, gCast).image = member(gSize & "x" & gSize, gCast).image
- coordinateList = []
- coordinateList.add((the mouseH - sprite(1).left) * 2 / gVariable / 2)
- coordinateList.add((the mouseV - sprite(1).top) * 2 / gVariable / 2)
- member(gSize & "x" & gSize, gCast).image.setPixel((the mouseH - sprite(1).left) * 2 / gVariable / 2, (the mouseV - sprite(1).top) * 2 / gVariable / 2, gSecondColor)
- updateStage()
- myCurrentImage = duplicate(member(gSize & "x" & gSize, gCast).image)
- myCurrentPreview = duplicate(member("preview", gCast).image)
- repeat while the mouseDown
- if (((the mouseH - sprite(1).left) * 2 / gVariable / 2) = getAt(coordinateList, count(coordinateList) - 1)) and (((the mouseV - sprite(1).top) * 2 / gVariable / 2) = getAt(coordinateList, count(coordinateList))) then
- myCurrentImage.setPixel((the mouseH - sprite(1).left) * 2 / gVariable / 2, (the mouseV - sprite(1).top) * 2 / gVariable / 2, gSecondColor)
- else
- coordinateList.add((the mouseH - sprite(1).left) * 2 / gVariable / 2)
- coordinateList.add((the mouseV - sprite(1).top) * 2 / gVariable / 2)
- myCurrentImage.draw(getAt(coordinateList, 1), getAt(coordinateList, 2), getAt(coordinateList, 3), getAt(coordinateList, 4), [#shapeType: #line, #lineSize: 1, #color: gSecondColor])
- deleteAt(coordinateList, 1)
- deleteAt(coordinateList, 1)
- end if
- member(gSize & "x" & gSize, gCast).image.copyPixels(myCurrentImage, myCurrentImage.rect, myCurrentImage.rect)
- updateStage()
- put (the mouseH - sprite(1).left) * 2 / gVariable / 2 into field "location status X"
- put (the mouseV - sprite(1).top) * 2 / gVariable / 2 into field "location status Y"
- fnUpdatePreview()
- end repeat
- coordinateList = VOID
- sprite(35).pState = 0
- sendSprite(35, #setMember)
- member("state2 - " & gSize, gCast).image = member(gSize & "x" & gSize, gCast).image
- myCurrentImage = VOID
- myCurrentPreview = VOID
- put EMPTY into field "location status X"
- put EMPTY into field "location status Y"
- end
-
- on toolEraser
- member("state1 - " & gSize, gCast).image = member(gSize & "x" & gSize, gCast).image
- coordinateList = []
- coordinateList.add((the mouseH - sprite(1).left) * 2 / gVariable / 2)
- coordinateList.add((the mouseV - sprite(1).top) * 2 / gVariable / 2)
- member(gSize & "x" & gSize, gCast).image.copyPixels(member("2nd Color", gCast).image, rect(((the mouseH - sprite(1).left) * 2 / gVariable / 2) - 4, ((the mouseV - sprite(1).top) * 2 / gVariable / 2) - 4, ((the mouseH - sprite(1).left) * 2 / gVariable / 2) + 5, ((the mouseV - sprite(1).top) * 2 / gVariable / 2) + 5), rect(0, 0, 9, 9), [#maskImage: member(gEraserMask).image.createMask()])
- sprite(8).rect = rect(the mouseH - (gEraserSize * gVariable / 2), the mouseV - (gEraserSize * gVariable / 2), the mouseH + (gEraserSize * gVariable / 2), the mouseV + (gEraserSize * gVariable / 2))
- updateStage()
- myCurrentImage = duplicate(member(gSize & "x" & gSize, gCast).image)
- myCurrentPreview = duplicate(member("preview", gCast).image)
- repeat while the mouseDown
- if (getAt(coordinateList, 1) = ((the mouseH - sprite(1).left) * 2 / gVariable / 2)) and (getAt(coordinateList, 2) = ((the mouseV - sprite(1).top) * 2 / gVariable / 2)) then
- nothing()
- else
- coordinateList.add((the mouseH - sprite(1).left) * 2 / gVariable / 2)
- coordinateList.add((the mouseV - sprite(1).top) * 2 / gVariable / 2)
- numSteps = float(sqrt(power(getAt(coordinateList, 1) - getAt(coordinateList, 3), 2) + power(getAt(coordinateList, 2) - getAt(coordinateList, 4), 2))) + 1
- repeat with i = 1 to numSteps
- l = (getAt(coordinateList, 1) * (numSteps - float(i)) / numSteps) + (getAt(coordinateList, 3) * (float(i) / numSteps))
- t = (getAt(coordinateList, 2) * (numSteps - float(i)) / numSteps) + (getAt(coordinateList, 4) * (float(i) / numSteps))
- myCurrentImage.copyPixels(member("2nd Color", gCast).image, rect(l - 4, t - 4, l + 5, t + 5), rect(0, 0, 9, 9), [#maskImage: member(gEraserMask).image.createMask()])
- end repeat
- deleteAt(coordinateList, 1)
- deleteAt(coordinateList, 1)
- member(gSize & "x" & gSize, gCast).image.copyPixels(myCurrentImage, myCurrentImage.rect, myCurrentImage.rect)
- sprite(8).rect = rect(the mouseH - (gEraserSize * gVariable / 2), the mouseV - (gEraserSize * gVariable / 2), the mouseH + (gEraserSize * gVariable / 2), the mouseV + (gEraserSize * gVariable / 2))
- updateStage()
- end if
- put (the mouseH - sprite(1).left) * 2 / gVariable / 2 into field "location status X"
- put (the mouseV - sprite(1).top) * 2 / gVariable / 2 into field "location status Y"
- fnUpdatePreview()
- end repeat
- coordinateList = VOID
- sprite(35).pState = 0
- sendSprite(35, #setMember)
- member("state2 - " & gSize, gCast).image = member(gSize & "x" & gSize, gCast).image
- myCurrentImage = VOID
- myCurrentPreview = VOID
- put EMPTY into field "location status X"
- put EMPTY into field "location status Y"
- end
-